package com.pine.common.util.json;

import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.type.TypeFactory;

import java.lang.reflect.ParameterizedType;

/**
 * type引用封装,javaType取自范型T
 *
 * @author pine manage
 * @since 2024-10-30
 */
public abstract class TypeRef<T> {
    /**
     * javaType: 获取范型T
     */
    private final JavaType jt = TypeFactory.defaultInstance()
            .constructType(((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0]);

    public TypeRef() {
    }

    public JavaType getType() {
        return this.jt;
    }
}

